<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>导航栏</title>
    <link href="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/css/bootstrap.min.css" rel="stylesheet">
  <style>
    .navbar {
      background-image: url('../static/nav_bg.png');
      background-size: cover;
    }
    .navbar-brand {
      color: #fff;
      font-weight: bold;
    }
    .navbar-nav .nav-link {
      color: #fff;
    }
    .user-info {
      position: absolute;
      top: 100%;
      right: 0;
      background-color: #fff;
      padding: 10px;
      display: none;
    }
    .user-info.active {
      display: block;
    }
  </style>
</head>
<body>
  <nav class="navbar navbar-expand-lg navbar-dark">
    <div class="container">
      <a class="navbar-brand" href="#">
        <img src="../static/headimg.jpg" alt="Logo" width="30" height="30" class="d-inline-block align-text-top">
        网站名称
      </a>
      <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav ms-auto">
          <li class="nav-item">
            <a class="nav-link" href="#">页面1</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">页面2</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">页面3</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">
              <img src="../static/headimg.jpg" alt="User Avatar" width="30" height="30" class="rounded-circle">
            </a>
            <div class="user-info">
              <ul>
                <li>用户名：John Doe</li>
                <li>邮箱：johndoe@example.com</li>
                <li>电话：123-456-7890</li>
              </ul>
            </div>
          </li>
          <li class="nav-item">
            <form class="d-flex">
              <input class="form-control me-2" type="search" placeholder="搜索" aria-label="Search">
              <button class="btn btn-outline-light" type="submit">搜索</button>
            </form>
          </li>
        </ul>
      </div>
    </div>
  </nav>

<script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js"></script>
  <script>
    const userAvatar = document.querySelector('.nav-link img');
    const userInfo = document.querySelector('.user-info');

    userAvatar.addEventListener('mouseenter', function() {
      userInfo.classList.add('active');
    });

    userAvatar.addEventListener('mouseleave', function() {
      userInfo.classList.remove('active');
    });
  </script>
</body>
</html>
